package com.molichuxing.gateway.exception;

import java.util.HashMap;
import java.util.Map;

/**
 * goods服务错误码
 * 
 * @author zoumingyu
 * @date 2019年9月24日
 *
 */
public enum GoodsExceptionCodeEnum {
	/**
	 * 商品不存在
	 */
	NONENTITY(30501, "抱歉，该商品不存在"),
	/**
	 * 商品已被禁售
	 */
	PROHIBITION(30502, "抱歉，该商品已被禁售");

	final static private Map<Integer, GoodsExceptionCodeEnum> MAP = new HashMap<Integer, GoodsExceptionCodeEnum>() {
		private static final long serialVersionUID = -8414553247670306999L;
		{
			GoodsExceptionCodeEnum[] enums = GoodsExceptionCodeEnum.values();
			for (GoodsExceptionCodeEnum OrderExceptionCodeEnum : enums) {
				put(OrderExceptionCodeEnum.getCode(), OrderExceptionCodeEnum);
			}
		}
	};

	public static GoodsExceptionCodeEnum getEnum(Integer code) {
		return MAP.get(code);
	}

	public static String getEnumDesc(Integer code) {
		GoodsExceptionCodeEnum OrderExceptionCodeEnum = MAP.get(code);
		if (OrderExceptionCodeEnum != null) {
			return OrderExceptionCodeEnum.getMessage();
		}
		return "";
	}

	private Integer code;

	private String message;

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	private GoodsExceptionCodeEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
}
